package com.AllCases.FirstExample;

import java.util.Scanner;

public class Project1 {

    public static void main(String[] args) {
        int[] arr = {1, 7, 3, 4, 2, 8};
        MyTools m1 = new MyTools();
        m1.Bubble(arr);
        Scanner Myscanner = new Scanner(System.in);

    }
}

class MyTools {

    //冒泡算法
    public void Bubble(int[] arr) {
        for (int i = 0; i < arr.length; i++) {

            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        for (int k = 0; k < arr.length; k++) {
            System.out.print(arr[k] + " ");
        }
    }
}

